<!doctype html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/extras/spring-security" xmlns:auth=""
      class="x-admin-sm">
<auth:data uri="/system/loginlog/list.json"/>
<head>
    <th:block th:include="common/head::noXadmin('登录日志')"/>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row ">
        <div class="layui-col-md12">
            <div class="layui-card" id="queryBox">
                <div class="layui-card-body ">
                    <form class="layui-form layui-col-space5">
                        <div class="layui-inline layui-show-xs-block">
                            <input class="layui-input" autocomplete="off" placeholder="开始日" name="stime"
                                   id="start">
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <input class="layui-input" autocomplete="off" placeholder="截止日" name="etime"
                                   id="end"></div>
                        <div class="layui-inline layui-show-xs-block">
                            <input type="text" name="loginName" placeholder="账号" autocomplete="off"
                                   class="layui-input"></div>
                        <div class="layui-inline layui-show-xs-block">
                            <select name="fail" lay-verify="">
                                <option value="">状态</option>
                                <option value="0">成功</option>
                                <option value="1">失败</option>
                            </select>
                        </div>
                        <div class="layui-inline layui-show-xs-block">

                            <button class="layui-btn" lay-submit="" lay-filter="sreach">
                                <i class="layui-icon">&#xe615;</i></button>
                        </div>
                    </form>
                </div>

            </div>
            <div class="layui-card">
                <div class="split-line-y split-line-y-open">
                    <i class="fa "></i>
                </div>
                <div class="layui-card-body ">
                    <table class="layui-table" id="dataList" lay-filter="data"></table>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<th:block th:inline="none">
    <script type="text/html" id="statusTpl">
        {{#  if(!d.fail){ }}
        <button type="button" class="layui-btn  layui-btn-radius layui-btn-xs">正常</button>
        {{#  } }}
        {{#  if(d.fail){ }}
        <button type="button" class="layui-btn layui-btn-danger layui-btn-radius layui-btn-xs">异常</button>
        {{#  } }}
    </script>
    <script type="text/html" id="barTpl">
        <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">详情</a>
    </script>
    <script>
        layui.use(['jquery'], function () {
            var $ = layui.jquery;
            var queryBoxShow = true;
            $(".split-line-y >i").click(function () {
                if (queryBoxShow) {
                    queryBoxShow = false;
                    $("#queryBox").slideUp('fast');
                    $(".split-line-y").removeClass('split-line-y-open').addClass('split-line-y-closed');
                } else {
                    queryBoxShow = true;
                    $("#queryBox").slideDown('fast');
                    $(".split-line-y").removeClass('split-line-y-closed').addClass('split-line-y-open');
                }

            });
        })
        layui.use(['table', 'form'],
            function () {
                var table = layui.table,
                    form = layui.form;
                table.render({
                    elem: '#dataList'
                    , totalRow: false
                    , url: '/system/loginlog/list.json' //数据接口
                    , where: {
                        orderBy: 'ctime desc '
                    }
                    , page: true //开启分页
                    , response: {
                        statusCode: 0
                    }
                    , cols: [[
                        {field: 'loginId', title: '登录编号', fixed: 'left', width: 120}
                        , {field: 'userName', title: '账号', width: 100}
                        , {field: 'loginIp', title: '登录地址', minwidth: 140}
                        , {field: 'loginLocation', title: '登录地点', minwidth: 320}
                        , {field: 'loginBrowser', title: '浏览器', width: 100}
                        , {field: 'loginOs', title: '操作系统', width: 100}
                        , {field: 'remark', title: '备注', minwidth: 100}
                        , {field: 'fail', title: '状态', templet: '#statusTpl', width: 100}
                        , {field: 'ctime', title: '登录时间', minwidth: 180, sort: true, fixed: 'right'}
                    ]],
                    parseData: function (res) {
                        return {
                            code: res.code,
                            msg: res.message,
                            count: res.data.total,
                            data: res.data.list,
                            totalRow: {
                                score: "score",
                                experience: "exp"
                            }
                        }

                    }
                    , request: {
                        pageName: 'pageNum' //页码的参数名称，默认：page
                        , limitName: 'pageSize' //每页数据量的参数名，默认：limit
                    }
                })

                //监听工具条
                table.on('tool(data)',
                    function (obj) {
                        var data = obj.data
                            , event = obj.event //事件
                        ;
                        switch (event) {
                            case 'detail':
                                xadmin.open('明细', rootPath + 'system/loginlog/info?loginLogId=' + data.loginId)
                                break;
                        }
                    });
                table.on('sort(data)', function (obj) {
                    table.reload('dataList', {
                        page: {
                            curr: 1
                        },
                        initSort: obj,
                        where: {
                            orderBy: obj.field + ' ' + obj.type
                        }
                    });
                })
                form.on('submit(sreach)', function (data) {
                    table.reload('dataList', {
                            page: {
                                curr: 1
                            },
                            where: data.field
                        }
                    )
                    return false;
                })
            });</script>
    <script>layui.use('laydate',
        function () {
            var laydate = layui.laydate;

            //执行一个laydate实例
            laydate.render({
                elem: '#start' //指定元素
            });

            //执行一个laydate实例
            laydate.render({
                elem: '#end' //指定元素
            });
        });</script>
</th:block>
</html>